import sys

import requests

from api.Base import Login


class merProductComment(Login):
    # 查询评论
    def product_reply_list(self, nickname, productSearch):
        data = {
            'url': '/api/admin/merchant/product/reply/list',
            'method': 'get',
            'headers': {'Authori-zation': self._mer_token},
            'params': {
                'page': '1',
                'limit': '20',
                'isReply': '',
                'dateLimit': '',
                'nickname': nickname,
                'productSearch': productSearch,
                'temp': '1726640907',
            }
        }
        return self.mer_send_request(sys._getframe().f_code.co_name, data)

    # 添加自评
    def product_reply_virtual(self, productId, comment, nickname, star=5):
        data = {
            'url': '/api/admin/merchant/product/reply/virtual',
            'method': 'post',
            'headers': {'Authori-zation': self._mer_token},
            'json': {
                'avatar': 'https://crmebjavamer.oss-cn-beijing.aliyuncs.com/crmebimage/public/store/2024/08/09/329e096ada794a27993d7c1a9b3e6dfe1izzcb4g22.png',
                'productId': productId,
                'comment': comment,
                'nickname': nickname,
                'pics': [],
                'star': star,
                'attrValueId': 10950,
            }
        }
        return self.mer_send_request(sys._getframe().f_code.co_name, data)
        # 回复

    # 回复评论
    def product_reply_comment(self, pid, merchantReplyContent):
        data = {
            'url': '/api/admin/merchant/product/reply/comment',
            'method': 'post',
            'headers': {'Authori-zation': self._mer_token},
            'json': {
                'id': pid,
                'merchantReplyContent': merchantReplyContent,
            }
        }
        return self.mer_send_request(sys._getframe().f_code.co_name, data)

    # 删除评论
    def product_reply_delete(self, pid):
        data = {
            'url': f'/api/admin/merchant/product/reply/delete/{pid}',
            'method': 'post',
            'headers': {'Authori-zation': self._mer_token},
        }
        return self.mer_send_request(sys._getframe().f_code.co_name, data)

